package com.lordjoe.collectiveintelligence.data;

import java.util.*;

/**
 * com.lordjoe.collectiveintelligence.data.DataItem
 *
 * @author Steve Lewis
 * @date May 12, 2009
 */
public class DataItem implements IDataItem
{
    public static DataItem[] EMPTY_ARRAY = {};
    public static Class THIS_CLASS = DataItem.class;

    private final Map<IMeasurementType,IMeasurement> m_Measurements = new HashMap<IMeasurementType,IMeasurement>();

    public DataItem()
    {
    }

    public void addMeasurement(IMeasurement m)
    {
         m_Measurements.put(m.getType(),m);
    }

    public <T> IMeasurement<T> getMeasurement(IMeasurementType<T> type)
    {
        IMeasurement iMeasurement = m_Measurements.get(type);

        return iMeasurement;
    }

    public IMeasurement[] getMeasurements()
    {
        return  m_Measurements.values().toArray(IMeasurement.EMPTY_ARRAY);
    }

    public IMeasurementType[] getMeasurementTypes()
    {
        return  m_Measurements.keySet().toArray(IMeasurementType.EMPTY_ARRAY);
    }

}
